import Vue from "vue";

import "normalize.css/normalize.css"; // a modern alternative to CSS resets
import Element from "element-ui";
import "./styles/element-variables.scss";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import i18n from "./lang"; // internationalization
import "./icons"; // icon
import "./utils/error-log"; // error log
import request from "@/utils/request";

import VueDragFormdesign from "vue-drag-formdesign";
// import "./styles/vue-drag-formdesign.css";
import 'vue-drag-formdesign/lib/vue-drag-formdesign.css'
Vue.use(VueDragFormdesign);

// 层级列表
import ZkTable from "vue-table-with-tree-grid";
Vue.use(ZkTable);

import dataV from "@jiaminghi/data-view";
Vue.use(dataV);

import * as filters from "./filters"; // global filters
import {
  hasPermission,
  hasNoPermission,
  hasAnyPermission
} from "./utils/permissionDirect";

const Plugins = [hasPermission, hasNoPermission, hasAnyPermission];

Plugins.map(plugin => {
  Vue.use(plugin);
});

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
});

Vue.prototype.$post = request.post;
Vue.prototype.$get = request.get;
Vue.prototype.$put = request.put;
Vue.prototype.$delete = request.delete;
Vue.prototype.$download = request.download;
Vue.prototype.$upload = request.upload;
Vue.prototype.$login = request.login;

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App)
});
